package com.itheima.stock.controller;

import com.itheima.stock.service.UserService;
import com.itheima.stock.vo.req.LoginReqVo;
import com.itheima.stock.vo.resp.LoginRespVo;
import com.itheima.stock.vo.resp.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@RestController
@RequestMapping("/api")
public class UserController{
    @Autowired
    private UserService service;

    @GetMapping("user/test")
    public String getName(){
        return "itheima";
    }

    @PostMapping("/login")
    public R<LoginRespVo> login(@RequestBody LoginReqVo vo){
        System.out.println(vo);
        R<LoginRespVo> login = service.login(vo);
        return login;
    }

    //验证码生成
    @GetMapping("/captcha")
    public R<Map> generateCode(){
        R<Map> vo = service.generateCode();
        return vo;

    }
}